/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package root;

import Grafik.GrafikObject;
import Grafik.GrafikPoint;
import Grafik.GrafikRectangle;
import Grafik.GrafikTriangle;
import java.awt.Color;
import javax.swing.JApplet;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Bernhard
 */
public class MainApp extends JApplet {

    /**
     * Initialization method that will be called after the applet is loaded
     * into the browser.
     */
    @Override
    public void init(){
        control = Controler.getInstance();
        initComponents();
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        triangleButton = new javax.swing.JButton();
        rectangleButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        valueTable = new javax.swing.JTable();
        grafikPanel1 = new root.grafikPanel();
        clearAll = new javax.swing.JButton();
        errorLabel = new javax.swing.JLabel();
        buildFree = new javax.swing.JCheckBox();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        pointAx = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        pointAy = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        pointBx = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        pointBy = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        pointCx = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        pointCy = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        pointDx = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        pointDy = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();

        setPreferredSize(new java.awt.Dimension(760, 470));

        triangleButton.setText("Dreieck hinzufügen");
        triangleButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                triangleButtonActionPerformed(evt);
            }
        });

        rectangleButton.setText("Rechteck hinzufügen");
        rectangleButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rectangleButtonActionPerformed(evt);
            }
        });

        valueTable.setRowSelectionAllowed(false);
        updateTable();
        jScrollPane1.setViewportView(valueTable);

        javax.swing.GroupLayout grafikPanel1Layout = new javax.swing.GroupLayout(grafikPanel1);
        grafikPanel1.setLayout(grafikPanel1Layout);
        grafikPanel1Layout.setHorizontalGroup(
            grafikPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        grafikPanel1Layout.setVerticalGroup(
            grafikPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 265, Short.MAX_VALUE)
        );

        clearAll.setText("Alles Löschen");
        clearAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clearAllActionPerformed(evt);
            }
        });

        buildFree.setText("Frei Bauen");

        jLabel1.setText("Ax:");

        pointAx.setText("0");

        jLabel5.setText("y:");

        pointAy.setText("0");

        jLabel2.setText("Bx:");

        jLabel6.setText("y:");

        pointBy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pointByActionPerformed(evt);
            }
        });

        jLabel3.setText("Cx:");

        jLabel8.setText("y:");

        jLabel4.setText("Dx:");

        jLabel7.setText("y:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pointAx, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pointAy, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pointBx, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pointBy, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pointCx, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pointCy, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pointDx, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pointDy, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(pointAx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel1)
                .addComponent(jLabel5)
                .addComponent(pointAy)
                .addComponent(jLabel2)
                .addComponent(pointBx)
                .addComponent(jLabel6)
                .addComponent(pointBy)
                .addComponent(jLabel3)
                .addComponent(pointCx)
                .addComponent(jLabel8)
                .addComponent(pointCy)
                .addComponent(jLabel4)
                .addComponent(pointDx)
                .addComponent(jLabel7)
                .addComponent(pointDy))
        );

        jLabel9.setText("Angaben in Meter");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(grafikPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jScrollPane1)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 207, Short.MAX_VALUE)
                        .addComponent(buildFree))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(triangleButton, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(8, 8, 8)
                        .addComponent(rectangleButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(errorLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(clearAll)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(rectangleButton)
                                    .addComponent(triangleButton))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(errorLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGap(3, 3, 3)))
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(clearAll)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buildFree)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
                .addComponent(grafikPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel9)
                .addGap(4, 4, 4))
        );

    }// </editor-fold>

    private void triangleButtonActionPerformed(java.awt.event.ActionEvent evt){                                               
        if (checkTriangle()){
            GrafikTriangle tri = new GrafikTriangle(Integer.parseInt(pointAx.getText()), Integer.parseInt(pointAy.getText()), Integer.parseInt(pointBx.getText()), Integer.parseInt(pointBy.getText()), Integer.parseInt(pointCx.getText()), Integer.parseInt(pointCy.getText()));
            tri.setWindowHeight(grafikPanel1.getHeight());
            tri.setWindowWith(grafikPanel1.getWidth());
            if(!buildFree.isSelected()){
                if(tri.checkEdges()){
                    if (tri.is_orthogonal() != null){
                        control.addGrafikObject(tri);
                        addExtraTiangle(tri);
                    }else{
                        errorLabel.setText("Das Dreieck hat keinen Rechten Winkel");
                        errorLabel.setForeground(Color.red);
                    }
                }else{
                    errorLabel.setText("Die eingegebenen Werte Grenzen nich an");
                    errorLabel.setForeground(Color.red);
                }
            }else{
                if (tri.is_orthogonal() != null){
                    control.addGrafikObject(tri);
                }else{
                    errorLabel.setText("Das Dreieck hat keinen Rechten Winkel");
                    errorLabel.setForeground(Color.red);
                }
            }
        }
        grafikPanel1.clear();
        updateTable();
        clearInputFields();
        grafikPanel1.updateFromList();
    }                                              

    private void rectangleButtonActionPerformed(java.awt.event.ActionEvent evt){                                                
            if (checkRectangle()){
                GrafikRectangle rec = new GrafikRectangle(Integer.parseInt(pointAx.getText()), Integer.parseInt(pointAy.getText()),
                                                          Integer.parseInt(pointBx.getText()), Integer.parseInt(pointBy.getText()),
                                                          Integer.parseInt(pointCx.getText()), Integer.parseInt(pointCy.getText()),
                                                          Integer.parseInt(pointDx.getText()), Integer.parseInt(pointDy.getText()));
                rec.setWindowHeight(grafikPanel1.getHeight());
                rec.setWindowWith(grafikPanel1.getWidth());
                if(!buildFree.isSelected()){
                    if (rec.checkEdges()){
                        if (rec.istRechteck() && rec.checkEdges()){
                            control.addGrafikObject(rec);
                        }else{
                            errorLabel.setText("Die eingegebenen Werte bilden kein Rechteck");
                            errorLabel.setForeground(Color.red);
                        }
                    }else{
                        errorLabel.setText("Die eingegebenen Werte Grenzen nich an");
                        errorLabel.setForeground(Color.red);
                    }
                }else{
                    if (rec.istRechteck()){
                        control.addGrafikObject(rec);
                    }else{
                        errorLabel.setText("Die eingegebenen Werte bilden kein Rechteck");
                        errorLabel.setForeground(Color.red);
                    }
                }
            }
        grafikPanel1.clear();
        grafikPanel1.updateFromList();
        updateTable();
        clearInputFields();
    }                                               

    private void clearAllActionPerformed(java.awt.event.ActionEvent evt){                                         
        grafikPanel1.dangerClear();
        control.clearList();
        errorLabel.setText("");
        updateTable();
        clearInputFields();
    }                                        

    private void pointByActionPerformed(java.awt.event.ActionEvent evt){
        // TODO add your handling code here:
    }

    private void addExtraTiangle(GrafikTriangle tri){
        int newX;
        int newY;
        GrafikPoint point = tri.is_orthogonal();
        if (point.equals(tri.getA())){
            newX = (point.getX() + (tri.getC().getX() - tri.getA().getX()) + (tri.getB().getX() - tri.getA().getX()));
            newY = (point.getY() + (tri.getC().getY() - tri.getA().getY()) + (tri.getB().getY() - tri.getA().getY()));
            GrafikTriangle ntri = new GrafikTriangle(newX, newY, tri.getB().getX(), tri.getB().getY(), tri.getC().getX(), tri.getC().getY());
            ntri.setWindowWith(grafikPanel1.getWidth());
            ntri.setWindowHeight(grafikPanel1.getHeight());
            control.addGrafikObject(ntri);
        }else if (point.equals(tri.getB())){
            newX = (point.getX() + (tri.getC().getX() - tri.getB().getX()) + (tri.getA().getX() - tri.getB().getX()));
            newY = (point.getY() + (tri.getC().getY() - tri.getB().getY()) + (tri.getA().getY() - tri.getB().getY()));
            GrafikTriangle ntri = new GrafikTriangle(tri.getA().getX(), tri.getA().getY(), newX, newY, tri.getC().getX(), tri.getC().getY());
            ntri.setWindowWith(grafikPanel1.getWidth());
            ntri.setWindowHeight(grafikPanel1.getHeight());
            control.addGrafikObject(ntri);
        }else if (point.equals(tri.getC())){
            newX = (point.getX() + (tri.getA().getX() - tri.getC().getX()) + (tri.getB().getX() - tri.getC().getX()));
            newY = (point.getY() + (tri.getA().getY() - tri.getC().getY()) + (tri.getB().getY() - tri.getC().getY()));
            GrafikTriangle ntri = new GrafikTriangle(tri.getA().getX(), tri.getA().getY(), tri.getB().getX(), tri.getB().getY(), newX, newY);
            ntri.setWindowWith(grafikPanel1.getWidth());
            ntri.setWindowHeight(grafikPanel1.getHeight());
            control.addGrafikObject(ntri);
        }else{
            errorLabel.setText("Unbekannter Fehler beim Erstellen der Dreiecksspiegelung");
        }
    }

    private boolean checkSaveArea(GrafikObject g){

        return true;
    }

    private void clearInputFields(){
        pointAx.setText("");
        pointAy.setText("");
        pointBx.setText("");
        pointBy.setText("");
        pointCx.setText("");
        pointCy.setText("");
        pointDx.setText("");
        pointDy.setText("");
    }

    private boolean checkTriangle(){
        try{
            Integer.parseInt(pointAx.getText());
            Integer.parseInt(pointAy.getText());
            Integer.parseInt(pointBx.getText());
            Integer.parseInt(pointBy.getText());
            Integer.parseInt(pointCx.getText());
            Integer.parseInt(pointCy.getText());
        }catch (Exception e){
            errorLabel.setText("Alle Felder müssen ganzzahlige Werte enthalten");
            errorLabel.setForeground(Color.red);
            return false;
        }
        return true;
    }

    private boolean checkRectangle(){
        try{
            Integer.parseInt(pointAx.getText());
            Integer.parseInt(pointAy.getText());
            Integer.parseInt(pointBx.getText());
            Integer.parseInt(pointBy.getText());
            Integer.parseInt(pointCx.getText());
            Integer.parseInt(pointCy.getText());
            Integer.parseInt(pointDx.getText());
            Integer.parseInt(pointDy.getText());
        }catch (Exception e){
            errorLabel.setText("Alle Felder müssen ganzzahlige Werte enthalten");
            errorLabel.setForeground(Color.red);
            return false;
        }
        return true;
    }

    private void updateTable(){
        DefaultTableModel model = new DefaultTableModel(
                new Object[][]{},
                new String[]{
                    "Ax", "Ay", "Bx", "By", "Cx", "Cy", "Dx", "Dy", "Type", "Schwerpunkt x", "Schwerpunkt y"
                }) {

            boolean[] canEdit = new boolean[]{
                false, false, false, false, false, false, false, false, false, false, false
            };

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex){
                return canEdit[columnIndex];
            }
        };

        valueTable.getTableHeader().setReorderingAllowed(false);
        valueTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent lse){
                if (lse.getValueIsAdjusting()){
                    return;
                }
            }
        });
        RNr = 1;
        DNr = 1;
        for (int i = 0; i < control.getObjectsList().size(); i++){
            try{
                if (control.getObjectsList().get(i).getClass().equals(GrafikRectangle.class)){
                    model.insertRow(i, new Object[]{((GrafikRectangle) control.getObjectsList().get(i)).getA().getX(),
                                                    ((GrafikRectangle) control.getObjectsList().get(i)).getA().getY(),
                                                    ((GrafikRectangle) control.getObjectsList().get(i)).getB().getX(),
                                                    ((GrafikRectangle) control.getObjectsList().get(i)).getB().getY(),
                                                    ((GrafikRectangle) control.getObjectsList().get(i)).getC().getX(),
                                                    ((GrafikRectangle) control.getObjectsList().get(i)).getC().getY(),
                                                    ((GrafikRectangle) control.getObjectsList().get(i)).getD().getX(),
                                                    ((GrafikRectangle) control.getObjectsList().get(i)).getD().getY(),
                                                    "Rechteck " + RNr,
                                                    ((GrafikRectangle) control.getObjectsList().get(i)).getCenter().getX(),
                                                    ((GrafikRectangle) control.getObjectsList().get(i)).getCenter().getX()});
                    RNr++;
                }
                if (control.getObjectsList().get(i).getClass().equals(GrafikTriangle.class)){
                    model.insertRow(i, new Object[]{((GrafikTriangle) control.getObjectsList().get(i)).getA().getX(),
                                                    ((GrafikTriangle) control.getObjectsList().get(i)).getA().getY(),
                                                    ((GrafikTriangle) control.getObjectsList().get(i)).getB().getX(),
                                                    ((GrafikTriangle) control.getObjectsList().get(i)).getB().getY(),
                                                    ((GrafikTriangle) control.getObjectsList().get(i)).getC().getX(),
                                                    ((GrafikTriangle) control.getObjectsList().get(i)).getC().getY(),
                                                    "-",
                                                    "-",
                                                    "Dreieck " + DNr,
                                                    ((GrafikTriangle) control.getObjectsList().get(i)).getCenter().getX(),
                                                    ((GrafikTriangle) control.getObjectsList().get(i)).getCenter().getX()});
                    DNr++;
                }
            }catch (Exception e){
            }
        }
        valueTable.setModel(model);
        valueTable.getColumn("Ax").setPreferredWidth(10);
        valueTable.getColumn("Ay").setPreferredWidth(10);
        valueTable.getColumn("Bx").setPreferredWidth(10);
        valueTable.getColumn("By").setPreferredWidth(10);
        valueTable.getColumn("Cx").setPreferredWidth(10);
        valueTable.getColumn("Cy").setPreferredWidth(10);
        valueTable.getColumn("Dx").setPreferredWidth(10);
        valueTable.getColumn("Dy").setPreferredWidth(10);
        valueTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        valueTable.changeSelection(0, 0, true, false);
        valueTable.updateUI();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]){
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try{
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()){
                if ("Nimbus".equals(info.getName())){
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        }catch (ClassNotFoundException ex){
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }catch (InstantiationException ex){
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }catch (IllegalAccessException ex){
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }catch (javax.swing.UnsupportedLookAndFeelException ex){
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run(){
                new Main().setVisible(true);
            }
        });
    }
    //
    private Controler control;
    // Variables declaration - do not modify
    private javax.swing.JCheckBox buildFree;
    private javax.swing.JButton clearAll;
    private javax.swing.JLabel errorLabel;
    private root.grafikPanel grafikPanel1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField pointAx;
    private javax.swing.JTextField pointAy;
    private javax.swing.JTextField pointBx;
    private javax.swing.JTextField pointBy;
    private javax.swing.JTextField pointCx;
    private javax.swing.JTextField pointCy;
    private javax.swing.JTextField pointDx;
    private javax.swing.JTextField pointDy;
    private javax.swing.JButton rectangleButton;
    private javax.swing.JButton triangleButton;
    private javax.swing.JTable valueTable;
    // End of variables declaration
    private int RNr = 1;
    private int DNr = 1;
}
